﻿@using LanDBom.Models
@{
    ViewBag.Title = "Technology";
}


@section styles{

}

<from class="form-horizontal">
    <div class="col-lg-12" id="main">
        <div class="col-sm-2">基本信息</div>
        <div class="col-sm-6">其他</div>
    </div>
    <div class="col-lg-12">

        <div class="col-sm-5">
            <div class="col-lg-12">
                工艺种类
            </div>
            <table class="table table-sm gun">
                <thead class="thead-light">
                    <tr>
                        <th scope="col">序号</th>
                        <th scope="col">工艺分类编号</th>
                        <th scope="col">工艺分类名</th>
                        <th scope="col">操作</th>
                    </tr>
                </thead>
                <tbody data-spy="scroll">
                    @foreach (var item in ViewBag.liststee as List<Steelmaking>)
                        {
                            <tr>
                                <td>@item.ST_ID</td>
                                <td>@item.ST_bai</td>
                                <td>@item.ST_fne</td>
                                <td><a href="#" id="modifySteelmaking">修改</a>|<a href="#" id="Delsteelmaking">删除</a>|<a href="#" id="showlibray">详细</a></td>
                            </tr>
                        }
                </tbody>
            </table>
            <div class="col-lg-12" style="display:none" id="modStee">
                <div>序号:<input readonly="readonly" type="text" id="txtid"/></div>
                <div>工艺分类编号:<input readonly="readonly" type="text" id="txtnum"/></div>
                <div>工艺名:<input type="text" id="txtname"/></div>
                <div><button id="confirmmodify">确定</button><button id="exitmodify">退出</button></div>
            </div>
        </div>

        <div class="col-sm-5">
            <div class="col-lg-12">
                工艺标准
            </div>
            <table class="table table-sm gun">
                <thead class="thead-light">
                    <tr>
                        <th scope="col">序号</th>
                        <th scope="col">工艺编号</th>
                        <th scope="col">工艺名</th>
                        <th scope="col">单位</th>
                        <th scope="col">价格</th>
                        <th scope="col">损耗</th>
                        <th scope="col">操作</th>
                    </tr>
                </thead>
                <tbody data-spy="scroll" id="tdodylibray">
                </tbody>
            </table>
        </div>
    </div>
</from>


@section scripts
{
    <script src="~/Scripts/jquery-3.4.1.min.js"></script>
    <script src="~/Scripts/bootstrap.min.js"></script>
    <script>
        //工艺分类修改
        $(function () {
            //弹出折叠床并传输数据
            $("#modifySteelmaking").click(function (e) {
                $("#modStee").css({ "display": "block" })
                st_id = $(e.target).parent().prev().prev().prev().val()
                st_bian = $(e.target).parent().prev().prev().val()
                st_fne = $(e.target).parent().prev().val()
                $("#txtnum").text(st_bian)
                $("#txtname").text(st_fne)
                $("#txtid").text(st_id)


            })
            //提交修改

            $("confirmmodify").click(function () {
                var msg = {
                    ST_bian: $("#txtnum").val(),
                    ST_fne: $("#txtname").val(),
                }
                $.ajax({
                    url: "//",
                    type: "POST",
                    data: msg,
                    success: function (data) {
                        if (data == "修改成功")
                            alert(data);
                    },
                    error: function (data) {
                        alert("erroer");
                    },
                })
            })

            //关闭折叠窗
            $("#exitmodify").click(function () {
                $("#modStee").css({ "display": "none" })
            })
        })

        //点击根据选择的工艺分类，显示具体工艺
        $(function () {
            var st_id = -99;
            $("#showlibray").click(function () {
                st_id = $(e.target).parent().prev().prev().prev().text()
                $.ajax({
                    url: '/Technology/Technology',
                    type: 'GET',
                    data: { "ST_ID": st_id },
                    success: function (dataarea) {
                        createRow3(dataarea);
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            })

        })
        //加载具体工艺
        function createRow(data) {
            $('#tdodylibray tr').remove();
            $.each(data, function (i, item) {
                var $div = $(`
                   <tr>
                        <td>${item.LB_ID}</td>
                        <td>${item.LB_bai}</td>
                        <td>${item.LB_fne}</td>
                        <td>${item.LB_dan}</td>
                        <td>${item.LB_jia}</td>
                        <td>${item.LB_shun}</td>
                        <td><a href="#">修改</a>|<a id="Dellibray" href="#">删除</a></td>
                    </tr>
                    `);
                $('#tdodylibray').append($div);
            })
        }
        //删除
        //删除选择的工艺分类
        $(function () {
            var st_id = -99;
            $("#Delsteelmaking").click(function () {
                if (!confirm('确定要删除该工艺分类吗?'))
                    return;
                st_id = $(e.target).parent().prev().prev().prev().text()
                $.ajax({
                    url: '/Technology/Del_steelmaking',
                    type: 'POST',
                    data: { "ST_ID": st_id },
                    success: function (data) {
                        alert(data);
                        if (data == "删除成功") {
                            $(e.target).parent('td').remove();
                        }
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            })
        })
        //删除选择的工艺
        $(function () {
            var lb_id = -99;
            $("#Dellibray").click(function () {
                if (!confirm('确定要删除该工艺吗?'))
                    return;
                lb_id = $(e.target).parent().prev().prev().prev().prev().prev().prev().text()
                $.ajax({
                    url: '/Technology/Del_libray',
                    type: 'POST',
                    data: { "LB_ID": lb_id },
                    success: function (data) {
                        alert(data);
                        if (data == "删除成功") {
                            $(e.target).parent('td').remove();
                        }
                    },
                    error: function () {
                        alert('Request Error');
                    }
                })
            })
        })
    </script>

}